package com.template.wrapper;

import lombok.Data;

import java.io.Serializable;

@Data
public class JsonResult<T> implements Serializable {
    private T data;
    private String code = "200";
    private String msg;

    public JsonResult(T data) {
        this.data = data;
    }

    public JsonResult(T data, String code, String msg) {
        this.data = data;
        this.code = code;
        this.msg = msg;
    }

    public static <T>JsonResult<T> succeed(T data){
        return new JsonResult<>(data);
    }

    public static <T>JsonResult<T> failed(String msg){
        return new JsonResult<>(null,"500",msg);
    }
}
